<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>map方法的应用</title>
</head>
<body>
    <script type="text/javascript">
        var oldArray = [
            {
                name: '张三',
                age: 17
            },
            {
                name: 'mjj',
                age: 29
            },
            {
                name: '李四',
                age: 30
            }
        ];
        /*
        var newNames = [];
        var newAges = [];
        for(var i = 0; i < oldArray.length; i++) {
            var myname = oldArray[i].name;
            var myage = oldArray[i].age;
            newNames.push(myname);
            newAges.push(myage);
        }
        console.log(newNames);
        console.log(newAges);
        */
       var newNames = oldArray.map(function(item,index){
           return item.name
       })
       var newAges = oldArray.map(function(item,index){
           return item.age
       })
       console.log(newNames);
       console.log(newAges);

    </script>
</body>
</html>